<template>
  <div>
    <!--  分割线-->
    <el-divider></el-divider>
    <!--垂直分割-->
    <span style="font-weight:bold"><span style="color:royalblue">|</span>&nbsp;基本资料</span>
    <!--  分割线-->
    <el-divider></el-divider>
    <!--     基本资料 -->
    <el-form :label-position="labelPosition" :rules="rules" label-width="80px" :model="insertForm">
      <el-row>
        <el-col :span="12">
          <el-form-item label="姓名:" prop="empName">
            <el-input v-model="insertForm.empName"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="出生日期:" prop="empBirthdate">
            <el-date-picker style="width: 100%" v-model="insertForm.empBirthdate"></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="性别:" prop="empSex">
            <el-radio-group v-model="insertForm.empSex">
              <el-radio label="M">男</el-radio>
              <el-radio label="F">女</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="是否在职:" prop="empWorkstatus">
            <el-radio-group v-model="insertForm.empWorkstatus">
              <el-radio label="Y">在职</el-radio>
              <el-radio label="N">离职</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="证件类型:" prop="empPaperstype">
            <el-select style="width: 100%" clearable v-model="insertForm.empPaperstype" placeholder="请选择证件类型">
              <el-option label="身份证" value="身份证"></el-option>
              <el-option label="通行证" value="通行证"></el-option>
              <el-option label="护照" value="护照"></el-option>
              <el-option label="其他" value="其他"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="证件号:" prop="empPapersnum">
            <el-input v-model="insertForm.empPapersnum"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="最高学历:" prop="empHigthEducation">
            <el-select style="width: 100%" clearable v-model="insertForm.empHigthEducation" placeholder="请选择最高学历">
              <el-option label="无" value="无"></el-option>
              <el-option label="初中" value="初中"></el-option>
              <el-option label="高中" value="高中"></el-option>
              <el-option label="中专" value="中专"></el-option>
              <el-option label="大专" value="大专"></el-option>
              <el-option label="本科" value="本科"></el-option>
              <el-option label="博士" value="博士"></el-option>
              <el-option label="硕士" value="硕士"></el-option>
              <el-option label="研究生" value="研究生"></el-option>
              <el-option label="其他" value="其他"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="最高学位:" prop="empHigthDegree">
            <el-select style="width: 100%" clearable v-model="insertForm.empHigthDegree" placeholder="请选择最高学位">
              <el-option label="无" value="无"></el-option>
              <el-option label="博士学位" value="博士学位"></el-option>
              <el-option label="硕士学位" value="硕士学位"></el-option>
              <el-option label="其他" value="其他"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="所内身份:">
            <el-input v-model="insertForm.empPosition"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="民族:">
            <el-input v-model="insertForm.hrNationId"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="政治面貌:">
            <el-input v-model="insertForm.hrPoliticalId"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="婚姻情况:">
            <el-input v-model="insertForm.empMaritalsta"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="门禁号:">
            <el-input v-model="insertForm.empEntrancenum"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="专业部:">
            <el-input v-model="insertForm.hrSpecialtyId"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <!--垂直分割-->
    <span style="font-weight:bold"><span style="color:#4169e1">|</span>&nbsp;从业资料</span>
    <!--  分割线-->
    <el-divider></el-divider>
    <!--      从业资料-->
    <el-form :label-position="labelPosition" label-width="80px" :model="insertForm">
      <el-row>
        <el-col :span="12">
          <el-form-item label="执业类别:">
            <el-input v-model="insertForm.hrPractiseId"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="执业证号码:">
            <el-input v-model="insertForm.empPracnum"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="首次执业时间:">
            <el-date-picker style="width: 100%" v-model="insertForm.empPracdate"></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="首次执业地:">
            <el-input v-model="insertForm.empPracsite"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="资格证类别:">
            <el-input v-model="insertForm.hrCertifyId"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="资格证号码:">
            <el-input v-model="insertForm.empCertifynum"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="资格证取得方式:">
            <el-input v-model="insertForm.empGainway"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="资格证取得地:">
            <el-input v-model="insertForm.empGainsite"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="个人介绍:">
            <el-input v-model="insertForm.empIntroduce"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <!--垂直分割-->
    <span style="font-weight:bold"><span style="color:#4169e1">|</span>&nbsp;入职情况</span>
    <!--  分割线-->
    <el-divider></el-divider>
    <!--     入职情况 -->
    <el-form :label-position="labelPosition" label-width="80px" :model="insertForm">
      <el-row>
        <el-col :span="12">
          <el-form-item label="入职时间:">
            <el-date-picker style="width: 100%" v-model="insertForm.empEntrydate"></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="社保号码:">
            <el-input v-model="insertForm.empSocialNum"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="合同开始时间:">
            <el-date-picker style="width: 100%" type="date" v-model="insertForm.empContStartdate"></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="合同截止时间:">
            <el-date-picker style="width: 100%" v-model="insertForm.empContEnddate"></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="是否参保:">
            <el-radio-group v-model="insertForm.empInsured">
              <el-radio label="是">是</el-radio>
              <el-radio label="否">否</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <!--垂直分割-->
    <span style="font-weight:bold"><span style="color:#4169e1">|</span>&nbsp;联系信息</span>
    <!--  分割线-->
    <el-divider></el-divider>
    <!--联系信息-->
    <el-form :label-position="labelPosition" label-width="80px" :model="insertForm">
      <el-row>
        <el-col :span="12">
          <el-form-item label="手机号码:">
            <el-input v-model="insertForm.empPhone"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="照片:">
            <el-input v-model="insertForm.empPicture"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="联系电话:">
            <el-input v-model="insertForm.empContactPhone"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="联系地址:">
            <el-input v-model="insertForm.empSite"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="邮箱:">
            <el-input v-model="insertForm.empEmail"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="邮政编码:">
            <el-input v-model="insertForm.empPostcode"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="QQ号:">
            <el-input v-model="insertForm.empQq"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="微信号:">
            <el-input v-model="insertForm.empWechat"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="联系地址:">
            <el-input v-model="insertForm.empSite"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div class="addBut">
      <el-button type="primary" plain @click="insertHrEmp">提交</el-button>
      <el-button type="primary" plain @click="goBack">返回</el-button>
    </div>
  </div>
</template>

<script>
export default {
  name: "HrEmpInsert.vue",
  data(){
    return{
      labelPosition:'top',
      insertForm:{},
      rules: {
        empName: [
          { required: true, message: '请输入姓名', trigger: 'blur' },
        ],
        empBirthdate: [
          {required: true, message: '请选择出生日期', trigger: 'change' }
        ],
        empSex: [
          { required: true, message: '请选择性别', trigger: 'change' }
        ],
        empWorkstatus: [
          { required: true, message: '请选择是否在职', trigger: 'change' },
        ],
        empPaperstype: [
          { required: true, message: '请输入证件类型', trigger: 'change' },
        ],
        empPapersnum: [
          { required: true, message: '请输入证件号', trigger: 'blur' }
        ],
        empHigthEducation: [
          { required: true, message: '请选择最高学历', trigger: 'change' },
        ],
        empHigthDegree: [
          { required: true, message: '请输入最高学位', trigger: 'change' },
        ],
      }
    }
  },
  methods:{
    insertHrEmp(){
      this.$http.post(`hrEmp`,this.insertForm)
          .then(res => {
            if(res.data.data == "ok"){
              this.$notify({
                title: '成功',
                message: '添加成功!',
                type: 'success'
              }),
              this.$router.push({name:"HrEmp"})
            } else if (res.data.data == "nook"){
                this.$notify.error({
                  title: '错误',
                  message: '该员工已存在!'
                }),
                    this.$router.go(-1)
            }
          })
          .catch(function (error) {
            console.log(error);
          });
    },
    goBack() {
      this.$router.push({name:"HrEmp"})
    }
  }
}
</script>

<style scoped>
.addBut {
  text-align: center;
}
</style>